#include <rid.h>
#include <stdint.h>
#include <time.h>
#include <stdio.h>

#include "../w4.h"

/* #define W4_PRINT_CASE(CASE)			\ */
/* 	case CASE:				\ */
/* 	puts(#CASE);				\ */
/* 	break */

/* void */
/* print_w4(W4 *w) */
/* { */
/* 	switch (w->what) { */
/* 		W4_PRINT_CASE(Improj); */
/* 		W4_PRINT_CASE(Falj); */
/* 		W4_PRINT_CASE(Nuaj); */
/* 		W4_PRINT_CASE(Truj); */
/* 		/\* assumed *\/ */
/* 		W4_PRINT_CASE(Imprasu); */
/* 		W4_PRINT_CASE(Falasu); */
/* 		W4_PRINT_CASE(Nuasu); */
/* 		W4_PRINT_CASE(Truasu); */
/* 		/\* except *\/ */
/* 		W4_PRINT_CASE(Aimproj); */
/* 		W4_PRINT_CASE(Afalj); */
/* 		W4_PRINT_CASE(Anuaj); */
/* 		W4_PRINT_CASE(Atruj); */
/* 		W4_PRINT_CASE(Aimprasu); */
/* 		W4_PRINT_CASE(Afalasu); */
/* 		W4_PRINT_CASE(Anuasu); */
/* 		W4_PRINT_CASE(Atruasu); */
/* 		/\* assumed or justified *\/ */
/* 		W4_PRINT_CASE(Improper); */
/* 		W4_PRINT_CASE(False); */
/* 		W4_PRINT_CASE(Nuanced); */
/* 		W4_PRINT_CASE(True); */
/* 		/\* improper opposite *\/ */
/* 		W4_PRINT_CASE(Proj); */
/* 		W4_PRINT_CASE(Prasu); */
/* 		W4_PRINT_CASE(Proper); */
/* 		/\* false opposite *\/ */
/* 		W4_PRINT_CASE(UnFalj); */
/* 		W4_PRINT_CASE(Unfalasu); */
/* 		W4_PRINT_CASE(Unfalse); */
/* 		/\* nuanced opposite *\/ */
/* 		W4_PRINT_CASE(Defij); */
/* 		W4_PRINT_CASE(Defasu); */
/* 		W4_PRINT_CASE(Definite); */
/* 		/\* true opposite *\/ */
/* 		W4_PRINT_CASE(Untruj); */
/* 		W4_PRINT_CASE(Untruasu); */
/* 		W4_PRINT_CASE(Untrue); */
/* 		/\* justified or assumed *\/ */
/* 		W4_PRINT_CASE(Justified); */
/* 		W4_PRINT_CASE(Assumed); */
/* 		/\* logical *\/ */
/* 		W4_PRINT_CASE(Logij); */
/* 		W4_PRINT_CASE(Logasu); */
/* 		W4_PRINT_CASE(Logical); */
/* 		/\* illogical*\/ */
/* 		W4_PRINT_CASE(Illogij); */
/* 		W4_PRINT_CASE(Illogasu); */
/* 		W4_PRINT_CASE(Illogical); */
/* 		/\* possible *\/ */
/* 		W4_PRINT_CASE(Possij); */
/* 		W4_PRINT_CASE(Possasu); */
/* 		W4_PRINT_CASE(Possible); */
/* 		/\* impossible *\/ */
/* 		W4_PRINT_CASE(Impossij); */
/* 		W4_PRINT_CASE(Impossasu); */
/* 		W4_PRINT_CASE(Impossible); */
/* 		/\* unknown *\/ */
/* 		W4_PRINT_CASE(Unknown); */
/* 	default: */
/* 		puts("Not named!"); */
/* 	} */
/* } */

/* int */
/* main(int argc, char *argv[]) */
/* { */
/* 	W4 ans; */
/* 	W4 ans2; */
/* 	W4 ans3; */
/* 	Rid id; */

/* 	rid_set(id, NULL); */
/* 	w4_now(&ans2, Truj, id, id); */
/* 	w4_now(&ans, Truj, id, id); */
/* 	printf("%i\n", w4_or(&ans3, &ans, &ans2, id, id)); */
/* 	print_w4(&ans3); */
/* 	w4_not(&ans3, &ans3, id, id); */
/* 	print_w4(&ans3); */
/* 	return 0; */
/* } */

int
main(int argc, char *argv[])
{
	W4 w1;
	W4 w2;
	W4 w3;
	W4_relv relv;
	W4_ser ser;

	/* Init w1 with a when value of now and with random when and why since
	 * we aren't using w4 as part of a larger system like we should be.
	*/
	w4_now(&w1, True, NULL, NULL);

	/* change what value of w1 to False */
	w4_not(&w1, &w1, NULL, NULL);

	/* change what value of w2 to Improper with same when value as w1 */
	w4_init(&w2, Improper, &w1.when, NULL, NULL);

	/* change what value of w2 to Proper */
	w4_compl(&w2, &w2, NULL, NULL);

	/* set what value of w3 to False via 'and' */
	relv = w4_and(&w3, &w1, &w2, NULL, NULL);

	/* check relevance */
	switch (relv) {
	case W4_ONE_FIRST:
		printf("first expr relevant\n");
		break;
	case W4_ONE_SECOND:
		printf("second expr relevant\n");
		break;
	case W4_BOTH_FIRST:
		printf("both exprs relevant, but first more\n");
		break;
	case W4_BOTH_SECOND:
		printf("both exprs relevant, but second more\n");
		break;
	case W4_BOTH_SAME:
		printf("both exprs relevant, but same amount\n");
		break;
	}

	/* convert w3 to a form for serialization */
	w4_ser(ser, &w3);

	/* do something with ser like write to a file or something */

	/* read serialized form back to usable form */
	w4_deser(&w3, ser);
	return 0;
}
